<template>
	<view class="content" style="height: 100%;">
		<BaseNavBar :isnormal="false" title="设置接单类型" />
		<!-- body -->
		<view class="body" style="padding: 0 26px;">
			<!-- selected result -->
			<view class="type-list">
				<view :class="[current==idx?'type-item current':'type-item']" v-for="(item,idx) in typeList" :key="idx" @click="selectOne(idx)">
					<view class="title">{{item.type}}</view>
					<view class="content">
						<img :src="item.icon" alt="" class="img">
						<text class="name">{{item.name}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="page-btn" @click="updateType">确认修改</view>
	</view>
</template>

<script>
	import { getKindList,selectOption,updateUserInfor } from '../../api'
	export default {
		data() {
			return {
				typeList: [],
				current: '-1',
			}
		},
		mounted() {
			console.log('1111')
			this.getKindOption()
		},
		methods: {
			getKindOption() {
				getKindList('{}').then(res => {
					console.log('技能页===', res)
					if(res.status == 200) {
						this.typeList = res.data
						let orderTakeType = uni.getStorageSync('userInfo').orderTakeType
						if(orderTakeType){
							
						}
					}
					
				})
			},
			selectOne(idx){
				this.current = idx
			},
			updateType(){
				let data = {
					orderTakeType: this.typeList[this.current].type,
				}
				updateUserInfor(data).then(res => {
					console.log('个人信息页===', res)
					if (res.status == 200) {
						uni.showToast({
							title: '修改成功',
						})
						setTimeout(()=>{
							uni.navigateBack()
						},500)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.type-list{
	width: 100%;
	box-sizing: border-box;
	.type-item{
		margin-top: 20px;
		.title{
			font-size: 14px;
			color: #000;
			padding-bottom: 10px;
		}
		.content{
			width: 110px;
			height: 115px;
			box-sizing: border-box;
			border: 1px solid #DFDFDF;
			border-radius: 8px;
			padding: 9px;
			.img{
				width: 92px;
				height: 74px;
			}
			.name{
				display: block;
				font-size: 11px;
				color: #666;
				text-align: center;
				padding-top: 8px;
			}
		}
		&.current {
			.content{
				background: #EFF1F2;
				border-color: #2456E0;
			}
			.name{
				color: #2456E0;
				text-decoration: underline;
			}
		}
	}
}
</style>
